<template>
	<el-dialog title="联系人详情" v-model="visible" :close-on-click-modal="false" draggable width="880px">
		<el-descriptions :column="2" border>
			<el-descriptions-item label-align="center" label="姓名">{{ rowInfo?.name }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="接警号码">{{ rowInfo?.phone }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="归属单位">{{ rowInfo?.deptName }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="头衔">{{ rowInfo?.title }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="邮箱">{{ rowInfo?.email }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="电话通知">{{ rowInfo?.telephoneAlarm === 20 ? '已开启' : '已关闭' }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="短信通知">{{ rowInfo?.smsAlarm === 20 ? '已开启' : '已关闭' }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="公众号通知">{{ rowInfo?.officialAlarm === 20 ? '已开启' : '已关闭' }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="绑定数量">{{ rowInfo?.installCount }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="接警时段">{{ rowInfo?.alarmTime === 10 ? '全天报警' : '时段报警' }}</el-descriptions-item>
			<el-descriptions-item label-align="center" label="时段" v-if="rowInfo?.alarmTime === 20">
				<div>
					<el-tag v-for="item in rowInfo?.alarmContactsTimeList" :key="item.id" class="mr-2"
						><span>{{ item.startTime }}</span>
						<span>~</span>
						<span>{{ item.endTime }}</span></el-tag
					>
					<div v-if="!rowInfo?.alarmContactsTimeList.length">未设置时段，默认全天接警</div>
				</div>
			</el-descriptions-item>
		</el-descriptions>
		<template #footer>
			<span class="dialog-footer">
				<el-button @click="visible = false">关闭</el-button>
			</span>
		</template>
	</el-dialog>
</template>

<script setup lang="ts" name="AlarmWorkerDetail">
import { getObj } from '/@/api/installation/basicAlarmContacts';

// 定义变量内容
const visible = ref(false);
const rowInfo: any = reactive({});

// 打开弹窗
const openDialog = (id: string) => {
	visible.value = true;
	getObj(id).then((res) => {
		Object.assign(rowInfo, res.data);
	});
};
// 暴露变量
defineExpose({
	openDialog,
});
</script>
